<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./WEB-INF/Templates/default.xhtml">

            <ui:define name="content">
                <h:form>
                    <h:dataTable border="1" var="cave" value="#{BibliotekaBean.caves}">
                        <h:column>
                            <f:facet name="header"><h:outputText value="Caves" /></f:facet>
                            <h:outputText value="Cave dimension: #{cave.dimension}" />
                            <h:dataTable border="2" var="Dragon" value="#{cave.dragonCollection}">
                                <h:column>
                                    <f:facet name="header"><h:outputText value="Dragons" /></f:facet>
                                    <h:outputText value="#{Dragon.nickname}" />    
                                </h:column>
                                <h:column>
                                    <f:facet name="header"><h:outputText value="Wingspan" /></f:facet>
                                    <h:outputText value="#{Dragon.wingspan}" />    
                                </h:column>
                                <h:column>
                                    <f:facet name="header"><h:outputText value="Fire Color" /></f:facet>
                                    <h:outputText value="#{Dragon.fireColor}" />    
                                </h:column>
                                 <h:column>
                                    <f:facet name="header"><h:outputText value="Actions" /></f:facet>
                                    <h:commandButton value="Edit" action="#{EditHelperBean.edytuj}"/><br/>
                                        <h:commandButton value="Delete" action="#{EditHelperBean.usun}"/>
                                        <h:inputHidden value="#{Dragon}" />
                                </h:column>
                            </h:dataTable>
                        </h:column>
                    </h:dataTable>
                    <h:commandButton value="Add dragon" action="#{EditHelperBean.nowa}"/>
                    <h:commandButton value="Set Color for all dragons" action="#{EditHelperBean.zapytanieJPA}" />
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
